SetGfxDriver 1:Graphics 1024,768,8,2:SeedRnd MilliSecs() :SetBuffer FrontBuffer() 
Global in1,in2,sort1,facts,factz,facts2,factz2,facts3,factz3
in1 = CreateBank(10000):in2 = CreateBank(10000)sort1 = CreateBank(60):facts=CreateBank(125):factz=CreateBank(125):factz2=CreateBank(125):facts2=CreateBank(125):factz3=CreateBank(125):facts3=CreateBank(125)
Dim decode(1000000):	Dim aaa(60)
Dim encode(1000000)
decodet()



While Not KeyHit(1) 
ClsColor 0,0,0
Cls
randnum()
getnums()
getfacts()
getfacts2()

getnums2()


Flip
WaitMouse() 
Wend 

Function getfacts2()
	For y=0 To 4
	For x=0 To 4
	PokeInt sort1,x*5,PeekInt(factz,25*y+(x*5))
	Next
        sortrow()
	For x=0 To 4
	PokeInt facts2,5*(y*5+x),PeekByte (sort1,5*x)
	Next
	ttt = Int(""+ PeekByte (sort1,0*5) +""+PeekByte (sort1,1*5) +""+PeekByte (sort1,2*5)+""+PeekByte (sort1,3*5)+""+PeekByte (sort1,4*5))
	xx = encode(ttt*5)
	PokeInt factz2,y*5,xx	
	Color 0,0,255:Text 120,y*9+110,xx,False ,False 	
	Next

	For y=0 To 4
	PokeInt sort1,y*5,PeekInt(factz2,5*y)
	Next
        sortrow()
	For x=0 To 4
	PokeInt facts3,y*5,PeekByte (sort1,5*y)
	Next

	ttt = Int(""+ PeekByte (sort1,0*5) +""+PeekByte (sort1,1*5) +""+PeekByte (sort1,2*5)+""+PeekByte (sort1,3*5)+""+PeekByte (sort1,4*5))
	xx = encode(ttt*5)
	PokeInt factz3,y*5,xx	
	Color 255,255,255:Text 90,y*9+83,xx,False ,False 	

	
End Function

Function getfacts()
	For y=0 To 4
	For x=0 To 4
	PokeInt sort1,x*5,PeekInt(in1,5*(y*5+x))
	Next
        sortrow()
	For x=0 To 4
	PokeInt facts,5*(y*5+x),PeekByte (sort1,5*x)
	Next
	ttt = Int(""+ PeekByte (sort1,0*5) +""+PeekByte (sort1,1*5) +""+PeekByte (sort1,2*5)+""+PeekByte (sort1,3*5)+""+PeekByte (sort1,4*5))
	xx = encode(ttt*5)
	PokeInt factz,y*5,xx	
	Color 255,255,0:Text 1,y*9+30,xx,False ,False 	
	Next
	
	For y=0 To 4
	For x=0 To 4
	PokeInt sort1,x*5,PeekInt(in1,25*5+5*(y*5+x))
	Next
        sortrow()
	For x=0 To 4
	PokeInt facts,5*(y*5+x),PeekByte (sort1,5*x)
	Next
	ttt = Int(""+ PeekByte (sort1,0*5) +""+PeekByte (sort1,1*5) +""+PeekByte (sort1,2*5)+""+PeekByte (sort1,3*5)+""+PeekByte (sort1,4*5))
	xx = encode(ttt*5)
	PokeInt factz,25+y*5,xx	
	Color 255,255,0:Text 320,y*9+30,xx,False ,False 	
	Next

	
	For y=0 To 4
	For x=0 To 4
	PokeInt sort1,x*5,PeekInt(in1,50*5+5*(y*5+x))
	Next
        sortrow()
	For x=0 To 4
	PokeInt facts,5*(y*5+x),PeekByte (sort1,5*x)
	Next
	ttt = Int(""+ PeekByte (sort1,0*5) +""+PeekByte (sort1,1*5) +""+PeekByte (sort1,2*5)+""+PeekByte (sort1,3*5)+""+PeekByte (sort1,4*5))
	xx = encode(ttt*5)
	PokeInt factz,50+y*5,xx	
	Color 255,255,0:Text 1,y*9+200,xx,False ,False 	
	Next
	
	For y=0 To 4
	For x=0 To 4
	PokeInt sort1,x*5,PeekInt(in1,75*5+5*(y*5+x))
	Next
        sortrow()
	For x=0 To 4
	PokeInt facts,5*(y*5+x),PeekByte (sort1,5*x)
	Next
	ttt = Int(""+ PeekByte (sort1,0*5) +""+PeekByte (sort1,1*5) +""+PeekByte (sort1,2*5)+""+PeekByte (sort1,3*5)+""+PeekByte (sort1,4*5))
	xx = encode(ttt*5)
	PokeInt factz,75+y*5,xx	
	Color 255,255,0:Text 320,y*9+200,xx,False ,False 	
	Next
	
	For y=0 To 4
	For x=0 To 4
	PokeInt sort1,x*5,PeekInt(in1,100*5+5*(y*5+x))
	Next
        sortrow()
	For x=0 To 4
	PokeInt facts,5*(y*5+x),PeekByte (sort1,5*x)
	Next
	ttt = Int(""+ PeekByte (sort1,0*5) +""+PeekByte (sort1,1*5) +""+PeekByte (sort1,2*5)+""+PeekByte (sort1,3*5)+""+PeekByte (sort1,4*5))
	xx = encode(ttt*5)
	PokeInt factz,100+y*5,xx	
	Color 255,255,0:Text 150,y*9+110,xx,False ,False 	
	Next
End Function

Function sortrow()

	For xt=0 To 4
		aaa(xt*5)=PeekInt (sort1,xt*5)+1
	Next
	For x=5 To 1 Step -1
	maxx =0
	For xt=0 To 4
	xx = aaa(xt*5):If maxx<xx Then maxx=xx:yy2=xt*5
	Next 
	aaa(yy2) =-10:PokeByte sort1,yy2,x
	Next
End Function 

Function getnums2()
	For y=0 To 4
	For x=0 To 4
	Color 0,255,0:Text 30+x*60,300+y*9+30,PeekInt(in2,5*(y*5+x)),False ,False 
	Next
	Next
	For y=0 To 4
	For x=0 To 4
	Color 0,255,0:Text 350+x*60,300+y*9+30,PeekInt(in2,5*(y*5+x+25)),False ,False 
	Next
	Next
	For y=0 To 4
	For x=0 To 4
	Color 0,255,0:Text 30+x*60,300+y*9+200,PeekInt(in2,5*(y*5+x+50)),False ,False 
	Next
	Next
	For y=0 To 4
	For x=0 To 4
	Color 0,255,0:Text 350+x*60,300+y*9+200,PeekInt(in2,5*(y*5+x+75)),False ,False 
	Next
	Next
	For y=0 To 4
	For x=0 To 4
	Color 0,255,0:Text 180+x*60,300+y*9+110,PeekInt(in2,5*(y*5+x+100)),False ,False 
	Next
	Next				
	
End Function

Function getnums()
	For y=0 To 4
	For x=0 To 4
	Color 0,255,0:Text 30+x*60,y*9+30,PeekInt(in1,5*(y*5+x)),False ,False 
	Next
	Next
	For y=0 To 4
	For x=0 To 4
	Color 0,255,0:Text 350+x*60,y*9+30,PeekInt(in1,5*(y*5+x+25)),False ,False 
	Next
	Next
	For y=0 To 4
	For x=0 To 4
	Color 0,255,0:Text 30+x*60,y*9+200,PeekInt(in1,5*(y*5+x+50)),False ,False 
	Next
	Next
	For y=0 To 4
	For x=0 To 4
	Color 0,255,0:Text 350+x*60,y*9+200,PeekInt(in1,5*(y*5+x+75)),False ,False 
	Next
	Next
	For y=0 To 4
	For x=0 To 4
	Color 0,255,0:Text 180+x*60,y*9+110,PeekInt(in1,5*(y*5+x+100)),False ,False 
	Next
	Next				
	
End Function
Function randnum()
For i = 0 To 125 
t = Rand(0,65535):PokeInt in1,i*5, t:PokeInt in2,i*5, t
Next 
End Function

Function decodet()
y=0
For x1=1 To 5
For x2=1 To 5
For x3=1 To 5
For x4=1 To 5
For x5=1 To 5
If((x1 <> x2) And (x1<>x3) And (x1<>x4) And (x1<>x5) And (x2<>x3) And (x2<>x4) And (x2<>x5) And (x3<>x4) And (x3<>x5) And (x4<>x5)) decode(y*5) =x1+""+x2+""+x3+""+x4+""+x5:encode(Int(x1+""+x2+""+x3+""+x4+""+x5)*5)=y:y=y+1
Next
Next
Next
Next
Next
End Function